<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            display: flex;
            text-align: center;
        }
    </style>
</head>

<body>
    <div class="biaoqing"></div>
    <button class="up">上一页</button>
    <button class="down">下一页</button>
</body>

</html>
<script>
    let page = 1

    function j(e) {
        let str = ''
        for (var key in e) {
            str += `${key}=${e[key]}&`
        }
        return str.slice(0, str.length - 1)
    }
    function ajax(method, url, params, cb) {
        let xhr = new XMLHttpRequest()
        xhr.open(method, url + "?" + j(params))

        xhr.onreadystatechange = function () {
            if (xhr.readyState == 4) {
                cb(JSON.parse(xhr.responseText))
            }
        }
        xhr.send()
    }

    document.querySelector('.up').onclick = function () {
        if (page > 1) {
            ajax('get', `https://yantianfeng.com/api/emotion`, { page: --page, count: 10 }, function (data) {
                var str = data.emotions.map((item, index) => {
                    return `<div> <img src="${item.url}" />
                        <div> ${item.title}<div> </div>`
                }).join('')
                document.querySelector('.biaoqing').innerHTML = str
            })
        }
    }
    document.querySelector('.down').onclick = function () {
        if (page < 4) {
            ajax('get', `https://yantianfeng.com/api/emotion`, { page: ++page, count: 10 }, function (data) {
                var str = data.emotions.map((item, index) => {
                    return `<div> <img src="${item.url}" />
                        <div> ${item.title}<div> </div>`
                }).join('')
                document.querySelector('.biaoqing').innerHTML = str
            })
        }
    }
</script>